from django.db import models
from shop.models import QUser


class Store(models.Model):
    s_name = models.CharField(max_length=32)
    s_address = models.CharField(max_length=32)
    s_description = models.TextField()
    s_picture = models.ImageField(upload_to='img')
    S_Q = models.OneToOneField(to=QUser, on_delete=models.CASCADE, null=True, default=0)


class GoodsType(models.Model):
    type = models.CharField(max_length=32)
    t_picture = models.ImageField(upload_to='image')
    t_logo = models.ImageField(upload_to='image')


class Goods(models.Model):
    g_name = models.CharField(max_length=32)
    g_picture = models.ImageField(default='image/1.jpg', upload_to='image')
    g_price = models.FloatField()
    g_number = models.FloatField()
    g_unit = models.CharField(max_length=32, default='个')
    g_id = models.CharField(max_length=32)
    save_time = models.IntegerField()
    save_unit = models.CharField(max_length=32)
    publish_time = models.DateField(auto_now=True)
    g_description = models.CharField(max_length=32)
    g_store = models.ForeignKey(to=Store, on_delete=models.CASCADE, null=True, default=0)
    g_type = models.ForeignKey(to=GoodsType, on_delete=models.CASCADE)
